package GUILayer;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JMenuBar;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

public class PersonGUI extends JFrame{

	private JFrame frmPersonMenu;
	private static final long serialVersionUID = 7526472295622776147L;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					PersonGUI window = new PersonGUI();
					window.frmPersonMenu.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public PersonGUI() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmPersonMenu = new JFrame();
		frmPersonMenu.setTitle("Person menu");
		frmPersonMenu.setBounds(100, 100, 450, 300);
		frmPersonMenu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JButton btnOpretNyKunde = new JButton("Opret ny kunde");
		btnOpretNyKunde.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			new CreateCustomerGUI();
				
			}
		});
		
		JButton btnOpretNyMedarbejder = new JButton("Opret ny medarbejder");
		btnOpretNyMedarbejder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			new CreateEmployeeGUI();
						
			}
		});
		
		JButton btnTilbage = new JButton("Tilbage");
		btnTilbage.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			frmPersonMenu.dispose();	
			}
		});
		GroupLayout groupLayout = new GroupLayout(frmPersonMenu.getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(136)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(btnTilbage, GroupLayout.PREFERRED_SIZE, 159, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnOpretNyMedarbejder, GroupLayout.PREFERRED_SIZE, 159, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnOpretNyKunde, GroupLayout.PREFERRED_SIZE, 159, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(147, Short.MAX_VALUE))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(25)
					.addComponent(btnOpretNyKunde, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(btnOpretNyMedarbejder, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(btnTilbage, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(71, Short.MAX_VALUE))
		);
		frmPersonMenu.getContentPane().setLayout(groupLayout);
		
		JMenuBar menuBar = new JMenuBar();
		frmPersonMenu.setJMenuBar(menuBar);
		
		JMenu mnFiler = new JMenu("Filer");
		menuBar.add(mnFiler);
		
		JMenuItem mntmAfslutProgram = new JMenuItem("Afslut program");
		mntmAfslutProgram.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		mnFiler.add(mntmAfslutProgram);
		
		JMenu mnHjlp = new JMenu("Hj\u00E6lp");
		menuBar.add(mnHjlp);
		
		JMenuItem om = new JMenuItem("Om");
		om.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				showAbout();
			}
		});
		mnHjlp.add(om);
		frmPersonMenu.setVisible(true);
	}
	
	private void showAbout()
	{
		JOptionPane.showMessageDialog(frmPersonMenu, "Vestbjerg Byggecenter\n" + "Version 1.0", "About Vestbjerg Byggecenter", JOptionPane.INFORMATION_MESSAGE);
	}

}
